import IPy
import subprocess

ips = input("请输入要检查的网段：")
try:
    ips.replace('.', '').replace('/', '')
except ValueError as ve:
    print("请输入正确的IP地址格式")
ips = IPy.IP(ips)
for ip in ips:
    ip = "ping -n 4 -i -w 1 " + str(ip)
    print(ip)
    a = subprocess.run(ip, stdout=subprocess.PIPE, universal_newlines=True, shell=True)
    print(a.returncode)
